///////////////////////////////////////////////////////////////////////////////
//  File:       moneyinfo.h
//
//  Summary:    Handles currency conversion
//
//  Sample:     CSF Headlines
//
//---------------------------------------------------------------------
//  This file is part of the Microsoft Commerce Server 2002 SDK
//
//  Copyright (C) 2000 - 2001 Microsoft Corporation.  All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Commerce Server 2002 and/or on-line documentation. See these other
// materials for detailed information regarding Microsoft code samples. 
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
///////////////////////////////////////////////////////////////////////////////

#ifndef MONEYINFO__H
#define MONEYINFO__H

#include "commerce.h"       // IDictionary and ISimplelist definition
#include <atlbase.h>


class CMoneyInfo
{
public:
    int GetMode();
    CMoneyInfo();
    HRESULT InitCompatible(IDictionary *pdictOrder, LPCWSTR pwszCompId, IDispatch *pdispContext=NULL, BOOL bEnableConversion = TRUE);
    HRESULT Init(IDispatch *pdispOrder, LPCWSTR pwszCompId, IDispatch *pdispContext = 0, BOOL bEnableConversion = FALSE);
    HRESULT Init(IDictionary *pdictOrder, LPCWSTR pwszCompId, IDispatch *pdispContext = 0, BOOL bEnableConversion = FALSE);
    HRESULT RoundCurrency(CURRENCY in, CURRENCY &out) ;
    HRESULT CurrencyToInt(CURRENCY in, int &out, WCHAR *ResultDictAndKey=0);
    HRESULT IntToCurrency(int in, CURRENCY &out);
    HRESULT MultiplyMoney(CURRENCY &result, const CURRENCY &cy, double mul, WCHAR *ResultDictAndKey=0);
    HRESULT AddMoney(CURRENCY &result, const CURRENCY &cy1, const CURRENCY &cy2, WCHAR *ResultDictAndKey=0);
    HRESULT SubtractMoney(CURRENCY &result, const CURRENCY &cy1, const CURRENCY &cy2, WCHAR *ResultDictAndKey=0);

protected:
    HRESULT InitError(LPCWSTR pwszCompId, IDispatch *pdispContext);
    HRESULT ErrOverflow(BSTR bstrKey);
protected:
    int m_RoundingScale;
    int m_IntToCurrencyConversionScale; //ie US is 100, jpn is 10000
    int m_CurrencyMode;

public:
    CComPtr<IDispatch>      m_pdispContext;
    WCHAR                   m_wszCompId[50];
};


#endif /* #ifndef MONEYINFO__H*/

